package com.bob.web.common.constant;

import java.awt.print.PageFormat;
import java.awt.print.Pageable;
import java.awt.print.Printable;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

/**
 * 名称: Page<br>
 * 描述: 分页实体<br>
 * 类型: JAVA<br>
 * 最近修改时间:2017/7/11 16:00<br>
 *
 * @author BoYangsh
 * @version [版本号, V1.0]
 * @since 2017/7/11 16:00
 */
public class Page	<T> implements Serializable, Pageable {
	private static final long serialVersionUID = 7656324715139250778L;
	/**
	 * 当前页从哪一条开始
	 */
	private int index = -1;
	/**
	 * 页号(从0页开始)
	 */
	private int pageNo;
	/**
	 * 每页大小
	 */
	private int pageSize = 10;
	/**
	 * 总数量
	 */
	private long total;
	/**
	 * 过滤条件
	 */
	private LinkedHashMap<String, Object> filter = new LinkedHashMap<>();
	/**
	 * 查询结果
	 */
	private List<T> result = new ArrayList<>();

	public static long getSerialVersionUID() {
		return serialVersionUID;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public long getTotal() {
		return total;
	}

	public void setTotal(long total) {
		this.total = total;
	}

	public LinkedHashMap<String, Object> getFilter() {
		return filter;
	}

	public void setFilter(LinkedHashMap<String, Object> filter) {
		this.filter = filter;
	}

	public List<T> getResult() {
		return result;
	}

	public void setResult(List<T> result) {
		this.result = result;
	}

	@Override
	public int getNumberOfPages() {
		return 0;
	}

	@Override
	public PageFormat getPageFormat(int pageIndex) throws IndexOutOfBoundsException {
		return null;
	}

	@Override
	public Printable getPrintable(int pageIndex) throws IndexOutOfBoundsException {
		return null;
	}

	public int getIndex() {
		return index == -1 ? pageNo * pageSize : index;
	}

	public void setIndex(int index) {
		this.index = index;
	}
}
